package com.ken.checkviolationapp.adapter

import android.content.Context
import android.util.Log
import androidx.databinding.DataBindingUtil
import com.cimcitech.tebaoscreen.base.BaseHolder
import com.cimcitech.tebaoscreen.base.BaseRecyclerViewAdapter
import com.ken.base_http_library.oil_price.OilPriceResponse
import com.ken.checkviolationapp.R
import com.ken.checkviolationapp.bean.ANewsBean
import com.ken.checkviolationapp.bean.BNewsBean
import com.ken.checkviolationapp.bean.TypeInterf
import com.ken.checkviolationapp.databinding.ItemNews2Binding
import com.ken.checkviolationapp.databinding.ItemNewsBinding
import com.ken.checkviolationapp.databinding.ItemOilPriceBinding
import com.ken.rxhttp.news.Data

/**
 * @author by ken
 * Blog:
 * Date:2020/5/13
 * Description:
 */
class NewsAdapter<T>(ctx: Context, layoutRes: Int, mData: MutableList<T>) :
    BaseRecyclerViewAdapter<T>(ctx, R.layout.item_news, mData) {
    val TAG = NewsAdapter::class.java.name
    var list = mData as MutableList<TypeInterf>
    lateinit var itemNewsBinding: ItemNewsBinding
    lateinit var itemNews2Binding: ItemNews2Binding
    override fun convert(holder: BaseHolder, item: T, position: Int) {
        itemNewsBinding = DataBindingUtil.bind(holder.itemView)!!
//        itemNews2Binding = DataBindingUtil.bind(holder.itemView)!!
        if (item is ANewsBean) {
            itemNewsBinding.news = item
            Log.e(TAG,"ANewsBean..."+item.data.author_name)
        } else if (item is BNewsBean) {
//            itemNews2Binding.news = item

            Log.e(TAG,"BNewsBean..."+item.data.author_name)
        }


    }

    override fun getItemViewType(position: Int): Int {
        return list[position].getType()
    }
}